import { Component } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { NzMessageService } from 'ng-zorro-antd/message';
import { _HttpClient } from '@delon/theme';
import { SysGroup } from '@api/sys/model/sysGroup.model';
import { EditComponent } from 'src/app/routes/common/edit/edit.component';
import { SysGroupService } from '@api/sys/service/sysGroup.service';

@Component({
  selector: 'app-sys-group-edit',
  templateUrl: '../../../common/edit/edit.component.html'
})
export class SysGroupEditComponent extends EditComponent<SysGroup, String> {
  constructor(
    public modal: NzModalRef,
    public msgSrv: NzMessageService,
    public http: _HttpClient,
    public sysGroupService: SysGroupService
  ) {
    super(modal, msgSrv, http, sysGroupService);
    this.schema = {
      properties: {
        code: { type: 'string', title: '代码' },
        name: { type: 'string', title: '名称', maxLength: 30 },
        sort: { type: 'integer', title: '排序' },
        enabled: {
          type: 'string',
          title: '是否有效',
          enum: [
            { label: '是', value: 1 },
            { label: '否', value: 0 }
          ],
          default: 1
        },
        description: { type: 'string', title: '描述', maxLength: 140 }
      },
      required: ['code', 'name']
    };
    this.ui = {
      '*': {
        spanLabelFixed: 100,
        grid: { span: 12 }
      },
      $enabled: {
        widget: 'radio',
        styleType: 'button',
        buttonStyle: 'solid'
      },
      $description: {
        widget: 'textarea',
        grid: { span: 24 }
      }
    };
  }
}
